REM Do operations on Notes files
REM Called when a user click on an action from a sub menu
REM Title:      Director:Menus.IntNotes.Sub
REM Author:     Philip Ludlam
REM Version:    0.31 Beta, Saturday the 3rd of November, 2001
REM Copyright:  (C) Philip Ludlam 2001

REM This program is free software; you can redistribute it and/or modify it
REM under the terms of the GNU General Public License as published by the Free
REM Software Foundation; either version 2 of the License, or (at your option)
REM any later version.
REM
REM This program is distributed in the hope that it will be useful, but WITHOUT
REM ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
REM FITNESS FOR APARTICULAR PURPOSE. See the GNU General Public License for more
REM details.
REM
REM You should have received a copy of the GNU General Public License along with
REM this program; if not, write to the Free Software Foundation, Inc., 59 Temple
REM Place - Suite 330, Boston, MA 02111-1307, USA

ON ERROR PROCerror
REM *SPOOL scsi::4.$.DATA
REM TRACE ON

DIM block% 1023,syntax% 255,output% 255,file_area% 2047
file_size%=0:file_ptr%=0

Menu=FNswi_number("Director_Menu")
EndMenu=FNswi_number("Director_EndMenu")
Option=FNswi_number("Director_Option")
Command=FNswi_number("Director_Command")
Dash=FNswi_number("Director_Dash")

REM Get command line
SYS "OS_GetEnv" TO comm%
REM VDU4:PRINT FNstring(comm%)
SYS "OS_ReadArgs","name,quit,file,line",comm%,block%,1023

IF block%!8=0 THEN
  file$="Director:Menus.IntNotes.Notes.Notes"
ELSE
  file$=FNstring(block%!8)
  IF INSTR(file$,"$")=0 AND INSTR(file$,":")=0 file$="Director:Menus.IntNotes.Notes."+file$
ENDIF
line%=EVAL(FNstring(block%!12))

IF FNfile_valid(file$,1) THEN
  PROCfile_load(file$)

  line$=FNfile_read:lineno%=1
  WHILE line%>lineno%
    line$=FNfile_read:lineno%+=1
  ENDWHILE
  IF line$="" OSCLI("Unset Director$Menu"):END

  SYS "OS_ReadArgs","/a,priority/k,sub/k,notes/k",line$,block%,1024
  text$=FNstring(!block%)
  IF block%!4<>0 pri$="-fg <"+FNstring(block%!4)+">":pril$=FNlcase(FNstring(block%!4)) ELSE pri$="":pril$="standard"
  IF block%!8<>0 sub$=FNstring(block%!8) ELSE sub$=""
  IF block%!12<>0 notes$=FNstring(block%!12) ELSE notes$=""

  PROCmenu_note
ENDIF
*Set Director$Menu Note

END

:

DEF PROCmenu_note
IF LEN(text$)>11 THEN
  SYS Menu,""""+LEFT$(text$,10)+""" Note"
ELSE
  SYS Menu,""""+text$+""" Note"
ENDIF
REM If there is is an associated Notes file, then give a link to that
REM IF notes$<>"" VDU4:PRINT "Notes -sub ""Dynamic:/Director:Menus.IntNotes.Show -file """""+notes$+""""""""
IF notes$<>"" SYS Option,"Notes -sub ""Dynamic:/Director:Menus.IntNotes.Show -file """""+notes$+""""""""
REM IF there is a 'more info' file then do an 'Option -sub'
IF sub$<>"" SYS Option,"More -sub Path:"+sub$:SYS Command,"Do Filer_Run "+sub$
REM Give the option to edit the Notes entry
REM VDU4:PRINT "Edit -sub ""Dynamic:/Director:Menus.IntNotes.Edit -file """""+file$+""""" -line "+STR$(lineno%)+""""
SYS Option,"Edit -sub ""Dynamic:/Director:Menus.IntNotes.Edit -file """""+file$+""""" -line "+STR$(lineno%)+""""
SYS EndMenu
ENDPROC

:

DEF FNswi_number(n$)
SYS "OS_SWINumberFromString",,n$ TO a%
=a%

:

DEF FNstring(p%):LOCAL a$:a$=""
WHILE ?p%>31
  a$+=CHR$(?p%):p%+=1
  ENDWHILE:=a$

:

DEF FNstring_c(s%,l%):LOCAL a$,p%:a$="":p%=0
WHILE s%?p%>31 AND p%<l%
  a$+=CHR$(s%?p%):p%+=1
  ENDWHILE:=a$

:

REM want% = to what object type you want to find/are looking for
DEF FNfile_valid(file$,want%):LOCAL ans%
SYS "XOS_File",17,file$ TO ans%
=(ans%=want%)

:

DEF PROCfile_load(file$)
LOCAL len%
SYS "OS_File",16,file$,file_area% TO ,,,,len%
file_area%?len%=0
file_size%=len%
ENDPROC

:

DEF FNfile_read
LOCAL i$:i$=""
WHILE i$="" AND (file_size%-file_ptr%)<>0
  i$=FNstring_c(file_area%+file_ptr%,file_size%-file_ptr%)
  file_ptr%+=LEN(i$)+1
  ENDWHILE
=i$

:

DEF FNlcase(text$)

LOCAL Loop%,text2$
text2$=STRING$(LEN(text$)," ")
text2$=""

FOR Loop%=1 TO LEN(text$)
  chr%=ASC(MID$(text$,Loop%,1))
  IF chr%>64 AND chr%<91 chr%=chr%+32
  text2$+=CHR$(chr%)
NEXT

=text2$

:

DEF PROCerror
ON ERROR OFF
VDU 4
PRINT "Error in: !Director.Menus.IntNotes.Sub"
PRINT "Report:   ";REPORT$
PRINT "Line:     ";ERL
END

:
